﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Servidor.Objectos.RemoteActions;
using TiposComuns.Objectos;
using System.Collections;
using System.Runtime.CompilerServices;

namespace Servidor.Objectos
{
    [Serializable]
    public class Pendents 
    {
        #region Attritutes
        private SerializableDictionary<int, RemoteAction> actions 
            = new SerializableDictionary<int,RemoteAction>();

        public SerializableDictionary<int, RemoteAction> Actions
        {
            [MethodImpl(MethodImplOptions.Synchronized)]
            get { return actions; }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set { actions = value; }
        }
        #endregion

        #region Constructors
        public Pendents()
        {
            this.actions = new SerializableDictionary<int, RemoteAction>();
        }
        #endregion

        #region Methods

        [MethodImpl(MethodImplOptions.Synchronized)]
        public void Add(RemoteAction action)
        {
            lock (this.actions)
            {
                this.actions.Add(action.ID, action);
            }
        }

        [MethodImpl(MethodImplOptions.Synchronized)]
        public void Remove(int id)
        {
            lock (this.actions)
            {
                this.actions.Remove(id);
            }
        }

        [MethodImpl(MethodImplOptions.Synchronized)]
        public RemoteAction Get(int id)
        {
            return this.actions[id];
        }
        #endregion

        
    }
}
